package com.example.lock.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description redis test
 * @Author lihw
 * @Date 2023/11/16 14:07
 */
@RestController
@RequestMapping("redis")
public class RedisController {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @GetMapping("set")
    public void setValue(String key, String value) {
        redisTemplate.opsForValue().set(key, value);
    }

    @GetMapping("get")
    public Object getValue(String key) {
        return redisTemplate.opsForValue().get(key);
    }
}
